package net.ktims.khub.runtime;


import net.ktims.khub.WsParam;
import net.ktims.khub.WsParamSet;
import oracle.j2ee.ws.common.encoding.*;
import oracle.j2ee.ws.common.encoding.literal.*;
import oracle.j2ee.ws.common.encoding.simpletype.*;
import oracle.j2ee.ws.common.soap.SOAPEncodingConstants;
import oracle.j2ee.ws.common.soap.SOAPEnvelopeConstants;
import oracle.j2ee.ws.common.soap.SOAPVersion;
import oracle.j2ee.ws.common.streaming.*;
import oracle.j2ee.ws.common.wsdl.document.schema.SchemaConstants;
import javax.xml.namespace.QName;
import java.util.List;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class WsParamSet_LiteralSerializer extends LiteralObjectSerializerBase implements Initializable {
    private static final QName ns1_param_QNAME = new QName("", "param");
    private static final QName ns3_WsParam_TYPE_QNAME = new QName("http://ws.oi.khub.ktf.com/", "WsParam");
    private CombinedSerializer myWsParam_LiteralSerializer;
    
    public WsParamSet_LiteralSerializer(QName type) {
        this(type,  false);
    }
    
    public WsParamSet_LiteralSerializer(QName type, boolean encodeType) {
        super(type, true, encodeType);
    }
    
    public void initialize(InternalTypeMappingRegistry registry) throws Exception {
        myWsParam_LiteralSerializer = (CombinedSerializer)registry.getSerializer("", WsParam.class, ns3_WsParam_TYPE_QNAME);
    }
    
    public java.lang.Object doDeserialize(XMLReader reader,
        SOAPDeserializationContext context) throws Exception {
        WsParamSet instance = new WsParamSet();
        java.lang.Object member=null;
        QName elementName;
        List values;
        java.lang.Object value;
        
        reader.nextElementContent();
        elementName = reader.getName();
        if ((reader.getState() == XMLReader.START) && (elementName.equals(ns1_param_QNAME))) {
            values = new ArrayList();
            for(;;) {
                elementName = reader.getName();
                if ((reader.getState() == XMLReader.START) && (elementName.equals(ns1_param_QNAME))) {
                    myWsParam_LiteralSerializer.setNullable( true );
                    value = myWsParam_LiteralSerializer.deserialize(ns1_param_QNAME, reader, context);
                    values.add(value);
                    reader.nextElementContent();
                } else {
                    break;
                }
            }
            member = new WsParam[values.size()];
            member = values.toArray((java.lang.Object[]) member);
            instance.setParam((WsParam[])member);
        }
        else {
            instance.setParam(new WsParam[0]);
        }
        
        if( reader.getState() != XMLReader.END)
        {
            reader.skipElement();
        }
        XMLReaderUtil.verifyReaderState(reader, XMLReader.END);
        return (java.lang.Object)instance;
    }
    
    public void doSerializeAttributes(java.lang.Object obj, XMLWriter writer, SOAPSerializationContext context) throws Exception {
        WsParamSet instance = (WsParamSet)obj;
        
    }
    public void doSerializeAnyAttributes(java.lang.Object obj, XMLWriter writer, SOAPSerializationContext context) throws Exception {
        WsParamSet instance = (WsParamSet)obj;
        
    }
    public void doSerialize(java.lang.Object obj, XMLWriter writer, SOAPSerializationContext context) throws Exception {
        WsParamSet instance = (WsParamSet)obj;
        
        if (instance.getParam() != null) {
            for (int i = 0; i < instance.getParam().length; ++i) {
                myWsParam_LiteralSerializer.setNullable( true );
                myWsParam_LiteralSerializer.serialize(instance.getParam()[i], ns1_param_QNAME, null, writer, context);
            }
        }
    }
}
